<?php

/* 
 * Copyright (c) 2009 Nguyen Duc Thuan <me@ndthuan.com>
 * All rights reserved.
 */

class Fete_View_Helper_HeadTitle extends Fete_View_Helper
{
    protected $_title = '';
    protected $_tag = 'TITLE';

    /**
     *
     * @param string $title
     * @return Fete_View_Helper_HeadTitle
     */
    public function headTitle($title = null)
    {
        if (null !== $title) {
            $this->_title = $title;
        }

        return $this;
    }

    public function __construct()
    {
        if ('XHTML' === substr($this->docType()->getDocType(), 0, 5)) {
            $this->_tag = 'title';
        }
    }

    public function  __toString() {
        return '<' . $this->_tag . '>' . $this->_title
        . '</' . $this->_tag . '>';
    }
}